home *** CD-ROM | disk | FTP | other *** search
- head 1.2;
- branch ;
- access ;
- symbols ;
- locks ; strict;
- comment @ * @;
-
-
- 1.2
- date 90.06.26.19.00.51; author rab; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 90.04.13.11.10.38; author rab; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
- 1.2
- log
- @Fixed ON_EXIT macro to work correctly for sprite.
- @
- text
- @typedef struct set_vector
- {
- int length;
- int vector[1];
- /* struct set_vector *next; */
- } set_vector;
-
- #ifdef sprite
- set_vector __CTOR_LIST__;
- set_vector __DTOR_LIST__;
- static set_vector *__dlp;
- static int __dli;
- int __1xyzzy__;
- #else
- extern set_vector __CTOR_LIST__;
- extern set_vector __DTOR_LIST__;
- set_vector *__dlp;
- int __dli;
- #endif
-
- extern void exit ();
- extern void __do_global_init ();
- extern void __do_global_cleanup ();
- extern void on_exit(void*, void*);
-
- #if defined(i386) && !defined(sequent)
- #define COFF
- #endif
-
- #ifdef COFF_ENCAPSULATE
- #undef COFF
- #endif
-
- #if defined(sprite)
- #define ON_EXIT(PROCP) \
- do { extern void PROCP (); atexit (PROCP); } while (0)
- #endif
-
- int
- __main ()
- {
- /* Gross hack for GNU ld. This is defined in `builtin.cc'
- from libg++. */
- #ifndef COFF
- extern int __1xyzzy__;
- #endif
-
- #ifdef ON_EXIT
-
- #ifdef sprite
- ON_EXIT (_cleanup);
- #endif
-
- ON_EXIT (__do_global_cleanup);
-
- #endif
- __dli = __DTOR_LIST__.length;
- __dlp = &__DTOR_LIST__;
- #ifndef COFF
- __do_global_init (&__1xyzzy__);
- #else
- __do_global_init ();
- #endif
- }
-
- #ifndef ON_EXIT
- void
- exit (status)
- int status;
- {
- __do_global_cleanup ();
- _cleanup ();
- _exit (status);
- }
- #endif
-
- void
- __do_global_init ()
- {
- register int i, len;
- register void (**ppf)() = (void (**)())__CTOR_LIST__.vector;
-
- len = __CTOR_LIST__.length;
- for (i = 0; i < len; i++)
- (*ppf[i])();
- }
-
- void
- __do_global_cleanup ()
- {
- while (__dlp)
- {
- while (--__dli >= 0)
- {
- void (*pf)() = (void (*)())__dlp->vector[__dli];
- (*pf)();
- }
- __dlp = (struct set_vector *)__dlp->vector[__dlp->length];
- if (__dlp) __dli = __dlp->length;
- }
- }
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d8 7
- d19 1
- d34 3
- a36 3
- #if defined(sun)
- #define ON_EXIT(PROCP, ARG) \
- do { extern void PROCP (); on_exit (PROCP, ARG); } while (0)
- d50 2
- a51 2
- #ifdef sun
- ON_EXIT (_cleanup, 0);
- d54 1
- a54 1
- ON_EXIT (__do_global_cleanup, 0);
- @
-